home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / Compute`s Amiga resource 1.adf / Source / 8ColorWbench / Normalbench.a < prev    next >
Text File  |  1989-02-08  |  3KB  |  117 lines

  1. ;*************************************************************************
  2. ;
  3. ;    Normalbench.a
  4. ;
  5. ;    Return the Workbench screen to normal. (Reverses the effect of
  6. ; Colorbench.)
  7. ;
  8. ;*************************************************************************
  9.  
  10. ; Constants
  11.  
  12. _AbsExecBase    EQU    4    ;base addr for Exec
  13.  
  14. _CloseLibrary    EQU    -414
  15. _FreeRaster    EQU    -498
  16. _RemakeDisplay    EQU    -384
  17. _OpenWorkBench    EQU    -210
  18. _OpenLibrary    EQU    -552
  19.  
  20. LIB_VERSION    EQU    32    ;KS 1.2 or higher
  21. BITMAP        EQU    88    ;offset to BitMap structure
  22. DEPTH        EQU    5    ;offset to number of bitplanes
  23. WIDTH        EQU    12    ;offset to bitplane width
  24. HEIGHT        EQU    14    ;offset to bitplane height
  25. PLANES        EQU    16    ;offset to 3rd bitplane ptr
  26.  
  27.  
  28.  
  29.  
  30.     SECTION    Program,CODE
  31.  
  32. Start:
  33.     movea.l    _AbsExecBase,a6        ;get ptr to Exec library
  34.  
  35. ; open intuition library
  36.     lea    IntuitionName,a1    ;ptr to "intuition.library"
  37.     moveq.l    #LIB_VERSION,d0        ;set library version
  38.     jsr    _OpenLibrary(a6)    ;call OpenLibrary
  39.     move.l    d0,IntuitionBase    ;store the addr
  40.     beq    Exit            ;problem -- drop out
  41.  
  42. ; open graphics library
  43.     lea    GfxName,a1        ;ptr to "graphics.library"
  44.     moveq.l    #LIB_VERSION,d0        ;set library version
  45.     jsr    _OpenLibrary(a6)    ;call OpenLibrary
  46.     move.l    d0,GfxBase        ;store the addr
  47.     beq    CloseIntuition        ;problem -- drop out
  48.  
  49. ; get a ptr to the workbench screen structure using OpenWorkBench
  50.     movea.l IntuitionBase,a6    ;base addr of intuition library
  51.     jsr    _OpenWorkBench(a6)    ;call OpenWorkBench
  52.     move.l    d0,Scr            ;store the addr
  53.     beq    AllDone            ;problem -- drop out
  54.  
  55. ; get a ptr to the BitMap structure within the screen's RastPort structure
  56.     movea.l    Scr,a0
  57.     move.l    BITMAP(a0),bm
  58.  
  59. ; decide whether to discard a bitplane
  60.     movea.l    bm,a0
  61.     move.b    DEPTH(a0),d0
  62.     cmpi.b    #3,d0            ;3 bitplanes?
  63.     bne    AllDone            ;no
  64.  
  65. ; yes, so discard one
  66.     movea.l    Scr,a0
  67.     move.w    HEIGHT(a0),d1        ;height of bitplane in d1
  68.     move.w    WIDTH(a0),d0        ;width of bitplane in d0
  69.     movea.l    bm,a1
  70.     movea.l    PLANES(a1),a0        ;addr of bitplane in a0
  71.     movea.l    GfxBase,a6
  72.     jsr    _FreeRaster(a6)        ;call FreeRaster
  73.  
  74. ; set the number of bitplanes to 2
  75.     movea.l    bm,a0
  76.     move.b    #2,DEPTH(a0)        ;bm->DEPTH = 2
  77.  
  78. ; rebuild the display
  79.     movea.l    IntuitionBase,a6
  80.     jsr    _RemakeDisplay(a6)    ;call RemakeDisplay
  81.                     ;fall through to AllDone
  82.  
  83. ; finish by closing the libraries
  84. AllDone:
  85.     movea.l    GfxBase,a1        ;close graphics.library
  86.     movea.l    _AbsExecBase,a6
  87.     jsr    _CloseLibrary(a6)    ;call CloseLibrary
  88.  
  89. CloseIntuition:
  90.     movea.l    IntuitionBase,a1    ;close intuition.library
  91.     jsr    _CloseLibrary(a6)    ;call CloseLibrary
  92.  
  93. Exit:
  94.     rts                ;back to CLI
  95.  
  96.  
  97.  
  98.  
  99.     SECTION    InitData,DATA
  100.  
  101. IntuitionName:
  102.     dc.b    'intuition.library',0
  103. GfxName:
  104.     dc.b    'graphics.library',0
  105.  
  106.  
  107.  
  108.  
  109.     SECTION    UnInitData,BSS
  110.  
  111. Scr        ds.l 1
  112. bm        ds.l 1
  113. IntuitionBase    ds.l 1
  114. GfxBase        ds.l 1
  115.  
  116.     end
  117.